const express = require('express');
const router = express.Router();
const resumeController = require('../controllers/resumeController');
const { verifyToken } = require('../middlewares/auth');

/**
 * @swagger
 * /api/resume/invitation/{code}:
 *   get:
 *     summary: 获取邀请信息
 *     tags: [简历]
 *     parameters:
 *       - in: path
 *         name: code
 *         required: true
 *         schema:
 *           type: string
 *     responses:
 *       200:
 *         description: 成功获取邀请信息
 *       404:
 *         description: 邀请链接不存在
 */
router.get('/invitation/:code', resumeController.getInvitationByCode);

/**
 * @swagger
 * /api/resume/submit:
 *   post:
 *     summary: 提交简历
 *     tags: [简历]
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - linkToken
 *               - name
 *               - phone
 *               - gender
 *               - weight
 *               - photos
 *               - canDrink
 *               - canLivestream
 *               - preferredShift
 *               - weeklyAvailability
 *               - gameExperience
 *             properties:
 *               linkToken:
 *                 type: string
 *                 description: 邀请链接令牌
 *               name:
 *                 type: string
 *                 description: 姓名
 *               nickname:
 *                 type: string
 *                 description: 昵称（选填）
 *               phone:
 *                 type: string
 *                 description: 手机号码
 *               wechat:
 *                 type: string
 *                 description: 微信号（选填）
 *               gender:
 *                 type: string
 *                 enum: [male, female, other]
 *                 description: 性别
 *               age:
 *                 type: integer
 *                 description: 年龄（选填）
 *               weight:
 *                 type: number
 *                 description: 体重(kg)
 *               education:
 *                 type: string
 *                 enum: [高中/中专, 大专, 本科, 硕士, 博士, 其他]
 *                 description: 学历（选填）
 *               photos:
 *                 type: array
 *                 items:
 *                   type: string
 *                 description: 照片URL数组，1-5张
 *               hobbies:
 *                 type: string
 *                 description: 兴趣爱好（选填）
 *               specialSkills:
 *                 type: string
 *                 description: 才艺展示（选填）
 *               canDrink:
 *                 type: string
 *                 enum: [yes, no]
 *                 description: 可否饮酒
 *               canLivestream:
 *                 type: string
 *                 enum: [yes, no]
 *                 description: 能否配合直播宣传
 *               preferredShift:
 *                 type: string
 *                 enum: [day, night]
 *                 description: 期望工作时间
 *               weeklyAvailability:
 *                 type: string
 *                 description: 每周空闲时间描述
 *               workExperience:
 *                 type: array
 *                 items:
 *                   type: object
 *                   properties:
 *                     startDate:
 *                       type: string
 *                       format: date-time
 *                       description: 开始日期
 *                     endDate:
 *                       type: string
 *                       format: date-time
 *                       description: 结束日期
 *                     company:
 *                       type: string
 *                       description: 公司名称
 *                     position:
 *                       type: string
 *                       description: 职位
 *                     reasonForLeaving:
 *                       type: string
 *                       description: 离职原因
 *                 description: 工作经历（选填）
 *               gameExperience:
 *                 type: string
 *                 enum: [none, basic, familiar, expert]
 *                 description: 桌游与Switch熟悉程度
 *               selfIntroduction:
 *                 type: string
 *                 description: 自我介绍（选填）
 *     responses:
 *       201:
 *         description: 简历提交成功
 *       400:
 *         description: 请求参数错误
 */
router.post('/submit', resumeController.submitApplication);

/**
 * @swagger
 * /api/resume/upload-token:
 *   get:
 *     summary: 获取七牛云上传凭证
 *     tags: [简历]
 *     parameters:
 *       - in: query
 *         name: type
 *         required: true
 *         schema:
 *           type: string
 *         description: 文件类型，如 image
 *     responses:
 *       200:
 *         description: 成功获取上传凭证
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                 data:
 *                   type: object
 *                   properties:
 *                     token:
 *                       type: object
 *                       properties:
 *                         token:
 *                           type: string
 *                           description: 七牛云上传凭证
 *                         key:
 *                           type: string
 *                           description: 文件存储的唯一标识
 *                         domain:
 *                           type: string
 *                           description: 七牛云空间域名
 *       400:
 *         description: 无效的文件类型
 */
router.get('/upload-token', resumeController.getUploadToken);

/**
 * @swagger
 * /api/resume/{resumeId}/photos:
 *   put:
 *     summary: 更新简历照片
 *     tags: [简历]
 *     parameters:
 *       - in: path
 *         name: resumeId
 *         required: true
 *         schema:
 *           type: integer
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - photos
 *             properties:
 *               photos:
 *                 type: array
 *                 items:
 *                   type: string
 *     responses:
 *       200:
 *         description: 照片更新成功
 *       400:
 *         description: 照片格式错误
 *       404:
 *         description: 简历不存在
 */
router.put('/:resumeId/photos', resumeController.updateResumePhotos);

module.exports = router; 